package com.rbs.Controller;

import com.rbs.entity.Phone;
import com.rbs.service.Impl.PhoneServiceImpl;
import com.rbs.service.PhoneService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(urlPatterns = "/selectAllPhoneController")
public class SelectAllPhoneController extends HttpServlet {
    private PhoneService phoneService = new PhoneServiceImpl();
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        List<Phone> phoneList = phoneService.selectAll();
        //将list集合里边的内容存入request作用域中
        request.setAttribute("phoneList",phoneList);
        //转发到查所有里面
        request.getRequestDispatcher("/showAllPhone.jsp").forward(request,response);
    }
}
